/*{
author=pk2.2
}*/

namespace 据点耐久重设
{

    const bool 城市耐久提高 = true;
    const int gate_hp = 12000;
    const int port_hp = 5000;

    class Main
    {

        pk::building @building_;
        pk::building @city_;
        pk::building @port_;
        pk::building @gate_;

        Main()
        {
            pk::bind2(102, pk::trigger102_t(onGameStart), -2);
        }

        void onGameStart()
        {
            if (pk::get_scenario().loaded)
                return;

            if (pk::get_scenario().no == 血色剧本)
                return;

            update();

            return;
        }

        void update()
        {
            if (城市耐久提高)
            {
                for (int i = 0; i < 城市_末; i++)
                {
                    @city_ = pk::get_building(i);
                    int level = pk::max(0, ch::get_base_p(i).city_level) - 1;
                    int hp = 7000;

                    if (pk::is_large_city(pk::building_to_city(pk::get_building(i))))
                        hp += 2000;
                    hp += level * 1000;

                    if (i == 城市_洛阳 or i == 城市_长安 or i == 城市_建业 or i == 城市_洛阳 or i == 城市_成都)
                        hp += 2000;

                    pk::building_to_city(pk::get_building(i)).max_hp = hp;
                    city_.hp = pk::building_to_city(pk::get_building(i)).max_hp;

                    city_.update();
                }
            }

            for (int i = 城市_末; i < 据点_末; i++)
            {

                @gate_ = pk::get_building(i);
                if (gate_.facility == 设施_关隘)
                {

                    pk::building_to_gate(pk::get_building(i)).max_hp = gate_hp;
                    gate_.hp = pk::building_to_gate(pk::get_building(i)).max_hp;

                    gate_.update();
                }

                else
                {
                    @port_ = pk::get_building(i);
                    if (port_.facility == 设施_港口)
                    {
                        pk::building_to_port(pk::get_building(i)).max_hp = port_hp;
                        port_.hp = pk::building_to_port(pk::get_building(i)).max_hp;

                        port_.update();
                    }
                }
            }
        }

    }

    Main main;
}